package com.inspur.security.cbb3.kms.keymanager.secrets.service;

import com.inspur.security.cbb3.kms.keymanager.secrets.po.SecretsBean;
import com.inspur.security.cbb3.kms.keymanager.secrets.vo.AbstractSecretVO;
import com.inspur.security.cbb3.kms.keymanager.secrets.vo.KeyContentVO;
import com.inspur.security.cbb3.kms.keymanager.secrets.vo.SecretsAddVO;
import com.inspur.security.cbb3.kms.utils.PageRequestDate;
import javassist.NotFoundException;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.MissingServletRequestParameterException;

/**
 * @author: lijunchang
 * @Description: 密钥service
 * @Date: 2020/10/19
 */
public interface SecretsService {

    /**
     *
     * 根据密钥订单主键生成密钥
     * @param keyOrderUuid  密钥订单主键
     * @return  生成密钥信息
     */
    AbstractSecretVO generateKey(String keyOrderUuid);

    /**
     * 密钥分页查询
     * @param pageRequestDate   分页、排序对象
     * @param searchParams      查询条件
     * @return  返回结果集
     */
    Page searchSecrets(PageRequestDate pageRequestDate, SecretsBean searchParams);

    /**
     * 密钥信息单个查询
     * @param uuid  密钥主键
     * @return  密钥信息
     * @throws MissingServletRequestParameterException  缺少参数异常
     * @throws NotFoundException    未找到
     */
    SecretsBean searchSecret(String uuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 密钥删除，假删除
     * 密钥删除会同时将容器关联关系进行真删除
     * @param uuid 密钥主键
     * @throws MissingServletRequestParameterException  缺少参数异常
     * @throws NotFoundException    未找到
     */
    void deleteSecret(String uuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 密钥下载
     * @param uuid 密钥主键
     * @throws MissingServletRequestParameterException  缺少参数异常
     * @throws NotFoundException    未找到
     * @return  密钥字符串
     */
    String downloadSecret(String uuid) throws NotFoundException, MissingServletRequestParameterException;

    /**
     * 获取密钥明文，不需要权限认证
     * @param secretsUuid 密钥表uuid
     * @return 密钥明文
     */
    KeyContentVO getKeyContentNoAuth(String secretsUuid);

    /**
     * 进行密钥上传（新增）
     * @param secretsAddVO   密钥数据
     * @return  新增数据
     */
    SecretsBean uploadSecrets(SecretsAddVO secretsAddVO);
}
